from zope.interface import implements, Interface

from Products.Five import BrowserView
from Products.CMFCore.utils import getToolByName
from zope.component import getMultiAdapter

from my315ok.researchevent import researcheventMessageFactory as _


class IachievementView(Interface):
    """
    achievement view interface
    """

    def test():
        """ test method"""


class achievementView(BrowserView):
    """
    achievement browser view
    """
    implements(IachievementView)

    def __init__(self, context, request):
        self.context = context
        self.request = request


    def img_tag(self,scale="mini"):
        imgfd = self.context.getField("image")
        return imgfd.tag(self.context,scale=scale)
        
        
    def parent(self):
        parent = self.context.aq_inner.aq_parent
        return parent
    def parenturl(self):
        parenturl = self.parent().absolute_url()
        return parenturl
    def isrefer(self):
        
       try:
           self.context.getReference()
           return True
       except:
           return False
            
    def gettime(self,time):
        """fetch parent datetime"""
        pview = getMultiAdapter((self.parent(), self.request), name=u'earthqk_event_view')
        return pview.toLocalizedTime(time)
    def test(self):
        """
        test method
        """
        dummy = _(u'a dummy string')

        return {'dummy': dummy}
